package com.eregg.learn.netty.protocol.serialize;

import com.eregg.learn.netty.protocol.serialize.impl.JSONSerializer;

public interface Serializer {

    /**
     * json 序列化
     */
    byte JSON_SERIALIZER = 1;

    Serializer DEFAULT = new JSONSerializer();

    /**
     * 获取算法标识
     * @return
     */
    byte getSerializerAlogrithm();

    /**
     * 编码
     * @param object
     * @return
     */
    byte[] serialize(Object object);


    /**
     * 解码
     * @param clazz
     * @param bytes
     * @param <T>
     * @return
     */
    <T> T deserialize(Class<T> clazz, byte[] bytes);

}
